#include "stdafx.h"
#include "StrUtil.h"
#pragma hdrstop

const char * inf::FloatArrayToStringANSI( const float *array, const int length, const int precision ) {
  static int index = 0;
  static char str[4][16384];	// in case called by nested functions
  wchar_t i, n;
  char format[16], *s;

  // use an array of string so that multiple calls won't collide
  s = str[ index ];
  index = (index + 1) & 3;

//   inf::snPrintf( format, sizeof( format ), "%%.%df", precision );
//   n = snPrintf( s, sizeof( str[0] ), format, array[0] );
//   if ( precision > 0 ) {
//     while( n > 0 && s[n-1] == ConstChar<char>::_0 ) s[--n] = ConstChar<char>::StrZero;
//     while( n > 0 && s[n-1] == ConstChar<char>::Dot ) s[--n] = ConstChar<char>::StrZero;
//   }
//   inf::snPrintf( format, sizeof( format ), " %%.%df", precision );
//   for ( i = 1; i < length; i++ ) {
//     n += inf::snPrintf( s + n, sizeof( str[0] ) - n, format, array[i] );
//     if ( precision > 0 ) {
//       while( n > 0 && s[n-1] == ConstChar<char>::_0 ) s[--n] = ConstChar<char>::StrZero;
//       while( n > 0 && s[n-1] == ConstChar<char>::Dot ) s[--n] = ConstChar<char>::StrZero;
//     }
//   }
  return s;
}

const wchar_t * inf::FloatArrayToStringWIDE( const float *array, const int length, const int precision ) {
  static int index = 0;
  static wchar_t str[4][16384];	// in case called by nested functions
  int i, n;
  wchar_t format[16], *s;

  // use an array of string so that multiple calls won't collide
  s = str[ index ];
  index = (index + 1) & 3;

//   inf::snPrintf( format, sizeof( format ), L"%%.%df", precision );
//   n = snPrintf( s, sizeof( str[0] ), format, array[0] );
//   if ( precision > 0 ) {
//     while( n > 0 && s[n-1] == ConstChar<wchar_t>::_0 ) s[--n] = ConstChar<wchar_t>::StrZero;
//     while( n > 0 && s[n-1] == ConstChar<wchar_t>::Dot ) s[--n] = ConstChar<wchar_t>::StrZero;
//   }
//   inf::snPrintf( format, sizeof( format ), L" %%.%df", precision );
//   for ( i = 1; i < length; i++ ) {
//     n += inf::snPrintf( s + n, sizeof( str[0] ) - n, format, array[i] );
//     if ( precision > 0 ) {
//       while( n > 0 && s[n-1] == ConstChar<wchar_t>::_0 ) s[--n] = ConstChar<wchar_t>::StrZero;
//       while( n > 0 && s[n-1] == ConstChar<wchar_t>::Dot ) s[--n] = ConstChar<wchar_t>::StrZero;
//     }
//  }
  return s;
}
